/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.common.constant.knowledge;

import org.apache.commons.lang3.StringUtils;

/**
 * 层面指标关联威胁
 * @author zpy
 * @version 1.0.0
 */
public enum RelatedThreat {
    /**物理和环境安全关联威胁**/
    PHY_ENV(LayerTarget.PHY_ENV.getName(), ThreatType.PHY_ENV),
    /**网络和通信安全关联威胁**/
    NET_COMMUNICATION(LayerTarget.NET_COMMUNICATION.getName(),ThreatType.NET_COMMUNICATION),
    /**设备和计算安全关联威胁**/
    DEVICE_COMPUTE(LayerTarget.DEVICE_COMPUTE.getName(),ThreatType.DEVICE_COMPUTE),
    /**应用和数据安全关联威胁**/
    APP_DATA(LayerTarget.APP_DATA.getName(),ThreatType.APP_DATA),
    /**管理制度关联威胁**/
    MANAGE_SYSTEM(LayerTarget.MANAGE_SYSTEM.getName(),ThreatType.MANAGE),
    /**人员管理关联威胁**/
    PERSONNEL_MANAGE(LayerTarget.PERSONNEL_MANAGE.getName(),ThreatType.MANAGE),
    /**建设运行关联威胁**/
    BUILD_RUNNING(LayerTarget.BUILD_RUNNING.getName(),ThreatType.MANAGE),
    /**应急处置关联威胁**/
    EMERGENCY_HANDLING(LayerTarget.EMERGENCY_HANDLING.getName(),ThreatType.MANAGE);

    private final String name;
    private final ThreatType threatType;

    RelatedThreat(String name,ThreatType threatType) {
        this.name = name;
        this.threatType = threatType;
    }

    public static RelatedThreat fromName(String layerTargetName){
        RelatedThreat data = null;
        for(RelatedThreat tt : RelatedThreat.values()){
            if(StringUtils.equals(tt.getName(),layerTargetName)){
                data = tt;
                break;
            }
        }
        return data;
    }

    public String getName(){
        return this.name;
    }

    public ThreatType getThreatType(){
        return this.threatType;
    }
}